Full source code website bán hàng thương mại điện tử gần giống shopee
468.970 lượt xem;
1 <?
2 if (isset($_POST['butSaveLoai'])) {
3 $name=$_POST['txtName'];
4 $status=($_POST['chkShow']!=''?1:0);
5 $parent=$_POST['txtParent'];
6
7 $name = trim($_POST['txtName']);
8 if ($name=="")
9 {
10 echo "<p align=center class='err'>Bạn chưa nhập tên danh mục</p>";
11 }
12 else
13 {
14 if (!empty($_POST['oldid'])) {
15 $oldid = $_POST['oldid'];
16 $sql = "update doc_categories set doc_categories_name='".$name."', doc_categories_status='".$status."', doc_categories_parentid='".$parent."' where doc_categories_id='".$oldid."'";
17 }
18 else
19 $sql = "insert into doc_categories (doc_categories_name,doc_categories_parentid,doc_categories_status,date_added) values ('".$name."',".$parent.",".$status.",SYSDATE())";
20 if (mysql_query($sql,$con)) {
21 echo "<p align=center class='err'>Đã cập nhật thành công</p><br>";
22 echo "<script>window.location='index.php?act=edoc_category&page=".$_REQUEST['page']."&code=1'</script>";
23 }
24 else echo "<p align=center class='err'>Không thể cập nhật</p>";
25 }
26 }
27 ?>
28
29 <?
30 if (isset($_GET['id'])) {
31 $oldid=$_GET['id'];
32 $sql = "select * from doc_categories where doc_categories_id='".$oldid."'";
33 if ($result = mysql_query($sql,$con)) {
34 $row=mysql_fetch_array($result);
35 $name=$row['doc_categories_name'];
36 $status=$row['doc_categories_status'];
37 $parent=$row['doc_categories_parentid'];
38 }
39 }
40 ?>
41
42 <form method="POST" action="index.php?">
43 <input type=hidden name="act" value="edoc_category_m">
44 <input type=hidden name="oldid" value="<? echo $oldid; ?>">
45 <input type=hidden name="page" value="<? echo $_REQUEST['page']; ?>">
46 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
47 <tr>
48 <td width="45%" height="20" class="title" align="center">Thêm mới / Cập nhật
49 : Danh thư viện</td>
50 </tr>
51 <tr>
52 <td width="45%">
53 <table border="0" cellpadding="4" bordercolor="#111111" width="124%" id="AutoNumber2" cellspacing="0">
54 <tr>
55 <td width="15%" class="smallfont">
56 <p align="right">Tên danh mục</td>
57 <td width="1%" class="smallfont">
58 <font color="#FF0000">*</font></td>
59 <td width="83%" class="smallfont">
60 <INPUT value="<? echo $name; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
61 </tr>
62 <tr>
63 <td width="15%" class="smallfont" align="right">
64 Không cho hiển thị</td>
65 <td width="1%" class="smallfont">
66 </td>
67 <td width="83%" class="smallfont">
68 <input type="checkbox" name="chkShow" value="ON" <? if ($status>0) echo 'checked' ?>></td>
69 </tr>
70 <tr>
71 <td width="15%" class="smallfont">
72 <p align="right">Thuộc danh mục</td>
73 <td width="1%" class="smallfont">
74 </td>
75 <td width="83%" class="smallfont">
76 <select size="1" name="txtParent">
77 <?
78 echo "<option value='1'>[Danh mục gốc]</option>";
79 //$cats=GetListDoc(1);
80 //foreach ($cats as $cat)
81 //{
82 // if ($cat[0]==$parent)
83 // echo "<option value=".$cat[0]." selected>".$cat[1]."</option>";
84 // else
85 // echo "<option value=".$cat[0].">".$cat[1]."</option>";
86 // }
87 ?>
88 </select>
89
90 </td>
91 </tr>
92 <tr>
93 <td width="15%" class="smallfont">
94 <p align="right">
95 <INPUT TYPE="submit" NAME="butSaveLoai" VALUE="Cập nhật" CLASS=button> </td>
96 <td width="1%" class="smallfont">
97 </td>
98 <td width="83%" class="smallfont"><p align="left"> <INPUT TYPE="reset" CLASS=button value="Nhập lại"></td>
99 </tr>
100
101 </table>
102 </td>
103 </tr>
104 </table>
105 </form>
2 if (isset($_POST['butSaveLoai'])) {
3 $name=$_POST['txtName'];
4 $status=($_POST['chkShow']!=''?1:0);
5 $parent=$_POST['txtParent'];
6
7 $name = trim($_POST['txtName']);
8 if ($name=="")
9 {
10 echo "<p align=center class='err'>Bạn chưa nhập tên danh mục</p>";
11 }
12 else
13 {
14 if (!empty($_POST['oldid'])) {
15 $oldid = $_POST['oldid'];
16 $sql = "update doc_categories set doc_categories_name='".$name."', doc_categories_status='".$status."', doc_categories_parentid='".$parent."' where doc_categories_id='".$oldid."'";
17 }
18 else
19 $sql = "insert into doc_categories (doc_categories_name,doc_categories_parentid,doc_categories_status,date_added) values ('".$name."',".$parent.",".$status.",SYSDATE())";
20 if (mysql_query($sql,$con)) {
21 echo "<p align=center class='err'>Đã cập nhật thành công</p><br>";
22 echo "<script>window.location='index.php?act=edoc_category&page=".$_REQUEST['page']."&code=1'</script>";
23 }
24 else echo "<p align=center class='err'>Không thể cập nhật</p>";
25 }
26 }
27 ?>
28
29 <?
30 if (isset($_GET['id'])) {
31 $oldid=$_GET['id'];
32 $sql = "select * from doc_categories where doc_categories_id='".$oldid."'";
33 if ($result = mysql_query($sql,$con)) {
34 $row=mysql_fetch_array($result);
35 $name=$row['doc_categories_name'];
36 $status=$row['doc_categories_status'];
37 $parent=$row['doc_categories_parentid'];
38 }
39 }
40 ?>
41
42 <form method="POST" action="index.php?">
43 <input type=hidden name="act" value="edoc_category_m">
44 <input type=hidden name="oldid" value="<? echo $oldid; ?>">
45 <input type=hidden name="page" value="<? echo $_REQUEST['page']; ?>">
46 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
47 <tr>
48 <td width="45%" height="20" class="title" align="center">Thêm mới / Cập nhật
49 : Danh thư viện</td>
50 </tr>
51 <tr>
52 <td width="45%">
53 <table border="0" cellpadding="4" bordercolor="#111111" width="124%" id="AutoNumber2" cellspacing="0">
54 <tr>
55 <td width="15%" class="smallfont">
56 <p align="right">Tên danh mục</td>
57 <td width="1%" class="smallfont">
58 <font color="#FF0000">*</font></td>
59 <td width="83%" class="smallfont">
60 <INPUT value="<? echo $name; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
61 </tr>
62 <tr>
63 <td width="15%" class="smallfont" align="right">
64 Không cho hiển thị</td>
65 <td width="1%" class="smallfont">
66 </td>
67 <td width="83%" class="smallfont">
68 <input type="checkbox" name="chkShow" value="ON" <? if ($status>0) echo 'checked' ?>></td>
69 </tr>
70 <tr>
71 <td width="15%" class="smallfont">
72 <p align="right">Thuộc danh mục</td>
73 <td width="1%" class="smallfont">
74 </td>
75 <td width="83%" class="smallfont">
76 <select size="1" name="txtParent">
77 <?
78 echo "<option value='1'>[Danh mục gốc]</option>";
79 //$cats=GetListDoc(1);
80 //foreach ($cats as $cat)
81 //{
82 // if ($cat[0]==$parent)
83 // echo "<option value=".$cat[0]." selected>".$cat[1]."</option>";
84 // else
85 // echo "<option value=".$cat[0].">".$cat[1]."</option>";
86 // }
87 ?>
88 </select>
89
90 </td>
91 </tr>
92 <tr>
93 <td width="15%" class="smallfont">
94 <p align="right">
95 <INPUT TYPE="submit" NAME="butSaveLoai" VALUE="Cập nhật" CLASS=button> </td>
96 <td width="1%" class="smallfont">
97 </td>
98 <td width="83%" class="smallfont"><p align="left"> <INPUT TYPE="reset" CLASS=button value="Nhập lại"></td>
99 </tr>
100
101 </table>
102 </td>
103 </tr>
104 </table>
105 </form>